/**
 * \file  antiviral_imp_imline.h
 * \brief Inline methods of antiviral_imp class
 *
 * LAV: Lib Anti Virals
 * <http://lav.googlecode.com/>
 * Copyright (C) 2010 Velez Ezequiel, Peralta Andres, FuDePAN
 *
 * This file is part of the LAV project.
 *
 * Contents:       Inline methods of antiviral_imp class
 *
 * System:         LAV
 * Language:       C++
 *
 * Author:         Boretto Martin
 * E-Mail:         martinboretto@gmail.com
 *
 * Author:         Lenarduzzi Federico
 * E-Mail:         federicolenarduzzi@gmail.com
 * 
 * Author:         Alberione Fernando
 * E-Mail:         falberione037@gmail.com
 *
 * Author:         Ocampo Emanuel
 * E-Mail:         eocampo86@gmail.com
 *
 * LAV is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * LAV is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with LAV.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
#ifndef ANTIVIRAL_IMP_INLINE_H
#error Internal header file, DO NOT include this.
#endif

namespace lav
{

inline mili::bistream<> operator>> (mili::bistream<>& bis,
                ResisBasedAntiviral::ResistancePosition& res_position)
{
    size_t pos;
    string aminoacids;
    bis >> pos;
    bis >> aminoacids;
    res_position = ResisBasedAntiviral::ResistancePosition(pos, aminoacids, INITIAL_WEIGHT);  
    return bis;
}

inline mili::bostream<>& operator<< (mili::bostream<>& bos,
                const ResisBasedAntiviral::ResistancePosition& res_position)
{
    bos << res_position.pos << res_position.aminoacids;
    return bos;
}

inline bool ResisBasedAntiviral::ResistancesGroup::isValid() const
{
    return minResistanceWeight <= get_acumulated_weight(resistances);
}

inline bool ResisBasedAntiviral::ResistancesGroup::operator==(const ResistancesGroup& other) const
{
    return ((minResistanceWeight == other.minResistanceWeight) && (resistances == other.resistances));
}

inline mili::bistream<>& operator>> (mili::bistream<>& bis, ResisBasedAntiviral::ResistancePositionContainer& res)
{
    int size = 0, index = 0;
    bis >> size;
    while (index < size)
    {
	size_t pos;
	string aminoacids;
	bis >> pos;
	bis >> aminoacids;
	mili::insert_into(res, ResisBasedAntiviral::ResistancePosition(pos, aminoacids, INITIAL_WEIGHT));
    }
    return bis;
}

inline mili::bostream<>& operator<< (mili::bostream<>& bos, const ResisBasedAntiviral::ResistancePositionContainer& res)
{
    bos << res.size();
    for (ResisBasedAntiviral::ResistancePositionContainer::const_iterator it = res.begin(); it != res.end(); ++it)
    {
	bos << (*it).pos;
	bos << (*it).aminoacids;
    }

    return bos;
}

inline bool ResisBasedAntiviral::operator==(const ResisBasedAntiviral& other) const
{
  AntiviralIdentifier id_this;
  AntiviralIdentifier id_other;
  this->get_attrib("id", id_this);
  other.get_attrib("id", id_other);
  return (id_this == id_other);
}
    
}    
    
